package optimize

type test struct {
	a []int
}

// 指针接受者方法
func (t *test) aa() {
	t.a = t.a[:len(t.a)-1]
}

// 内存泄漏：slice
var s0 []int

func g(s1 []int) {
	// assume the length of s1 is much larger than 30
	s0 = s0[len(s1)-30:]
}
func gNoLeaking(s1 []int) {
	s0 = make([]int, 30)
	copy(s0, s1[len(s1)-30:])
}
